package com.ruoyi.legal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.legal.mapper.HolidayMapper;
import com.ruoyi.legal.domain.Holiday;
import com.ruoyi.legal.service.IHolidayService;

/**
 * 节假日值班Service业务层处理
 * 
 * @author xwj
 * @date 2025-05-06
 */
@Service
public class HolidayServiceImpl extends ServiceImpl<HolidayMapper, Holiday> implements IHolidayService {
    @Autowired
    private HolidayMapper holidayMapper;

    /**
     * 查询节假日值班
     * 
     * @param id 节假日值班主键
     * @return 节假日值班
     */
    @Override
    public Holiday selectHolidayById(Long id) {
        return holidayMapper.selectHolidayById(id);
    }

    /**
     * 查询节假日值班列表
     * 
     * @param holiday 节假日值班
     * @return 节假日值班
     */
    @Override
    public List<Holiday> selectHolidayList(Holiday holiday) {
        return holidayMapper.selectHolidayList(holiday);
    }

    /**
     * 新增节假日值班
     * 
     * @param holiday 节假日值班
     * @return 结果
     */
    @Override
    public Holiday insertHoliday(Holiday holiday) {

      //  holidayMapper.insertHoliday(holiday);
    save(holiday);
    return holiday;
    }

    /**
     * 修改节假日值班
     * 
     * @param holiday 节假日值班
     * @return 结果
     */
    @Override
    public Holiday updateHoliday(Holiday holiday) {

      //  holidayMapper.updateHoliday(holiday);
        updateById(holiday);
        return holiday;
    }

    /**
     * 批量删除节假日值班
     * 
     * @param ids 需要删除的节假日值班主键
     * @return 结果
     */
    @Override
    public int deleteHolidayByIds(Long[] ids) {
        return holidayMapper.deleteHolidayByIds(ids);
    }

    /**
    * 条件删除
    * @param holiday 节假日值班
    * @return
    */
    @Override
    public int delete(Holiday holiday) {
        QueryWrapper<Holiday> qw = new QueryWrapper<>();
        QueryTool.condition(qw, holiday);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param holiday 节假日值班
     * @return
     */
    @Override
    public Pages<Holiday> queryPage(Holiday holiday) {
        QueryWrapper<Holiday> qw = new QueryWrapper<>();
        QueryTool.condition(qw, holiday);
        IPage<Holiday> ipage = new Query<Holiday>().getPage(holiday);

        IPage<Holiday> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    @Override
    public List<Map> countNum(Holiday holiday) {
        return baseMapper.countNum(holiday);
    }

    @Override
    public List<Map> yearHolidays(Holiday holiday) {
        return baseMapper.yearHolidays(holiday);
    }

    /**
     * 删除节假日值班信息
     * 
     * @param id 节假日值班主键
     * @return 结果
     */
    @Override
    public int deleteHolidayById(Long id) {
        return holidayMapper.deleteHolidayById(id);
    }
}
